﻿using System;
using System.Web.Mvc;

using mvcForum.Core;

using mvcForum.Web.Areas.ForumAdmin.Helpers;
using mvcForum.Web.Controllers;
using mvcForum.Web.Interfaces;
using mvcForum.Core.Interfaces.Data;

namespace mvcForum.Web.Areas.ForumAdmin.Controllers {

	public class ForumController : ForumAdminBaseController {
		private readonly IRepository<Category> categoryRepo;
		private readonly IRepository<Core.Forum> forumRepo;
		private readonly IRepository<Group> groupRepo;
		private readonly IRepository<ForumAccess> accessRepo;

		public ForumController(IWebUserProvider userProvider, IContext context)
			: base(userProvider, context) {

			this.categoryRepo = this.GetRepository<Category>();
			this.forumRepo = this.GetRepository<Core.Forum>();
			this.groupRepo = this.GetRepository<Group>();
			this.accessRepo= this.GetRepository<ForumAccess>();
		}

		#region Read/Update
		public ActionResult Update(Int32 id) {
			// TODO: Validate access!
			Core.Forum forum = this.forumRepo.Read(id);

			return View(new mvcForum.Web.Areas.ForumAdmin.ViewModels.Forum { Id = id, CategoryId = forum.Category.Id, Path = BreadcrumbHelper.BuildPath(forum, Url), BoardId = forum.Category.Board.Id });
		}
		#endregion
	}
}